#include "Character/Character.h"
#include "Cats/CatsManager.h"
#include "Modifier/ModifierInstruction.h"
#include "GameModifier.h"

using namespace cocos2d;

//===== DESTRUCTOR =====
GameModifier::~GameModifier()
{
	_pCharacter = 0;
	_pCatsManager = 0;
}

//===== PUBLIC FUNCTIONS =====
/*!
    @function init
    @param		pCharacter : Character
				ref to Character
	@param		pCatsManager : CatsManager
				ref to CatsManager
    @result		sets up the environment for GameModifier
*/
void GameModifier::init(Character* pCharacter, CatsManager* pCatsManager)
{
	_pCharacter = pCharacter;
	_pCatsManager = pCatsManager;
}

/*!
    @function modify
    @param		pInstruction : ModifierInstruction
				run the provided instruction and pass in the appropriate ref
    @result		run the instruction which modifies the game difficulty
*/
void GameModifier::modify(ModifierInstruction* pInstruction)
{
	if( _pCharacter != 0 && _pCatsManager != 0 && pInstruction != 0)
	{
		pInstruction->runInstruction(_pCharacter, _pCatsManager);
		delete pInstruction;
	}
}
